define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'order/index/index' + location.search,
                    add_url: 'order/index/add',
                    edit_url: 'order/index/edit',
                    del_url: 'order/index/del',
                    multi_url: 'order/index/multi',
                    table: 'order',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                showToggle: false,
                showColumns: false,
                visible: false,
                showExport: false,
                commonSearch: false,
                columns: [
                    [
                        {checkbox: true},
                        // {field: 'id', title: __('Id')},
                        // {field: 'user_id', title: __('User_id')},
                        // {field: 'cate_id', title: __('Cate_id')},
                        // {field: 'estimate_id', title: __('Estimate_id')},
                        // {field: 'user.username', title: __('User.username')},
                        {field: 'user.nickname', title: __('User.nickname')},
                        {field: 'cate.cate_name', title: __('品牌')},
                        {field: 'order_no', title: __('Order_no')},
                        {field: 'price', title: __('Price'), operate:'BETWEEN'},//1待发货 2待签收 3待检测 4待打款 5待评价 6交易取消
                        {field: 'status', title: __('Status'),searchList: {"1": "已发货", "5":"待评价", "2":"待签收", "3":"待检测", "4":"待打款","6":"交易取消","7":"已完成"}
                            ,formatter: Table.api.formatter.normal},
                        {field: 'payment', title: __('Payment'),searchList: {"1": "微信", "0":"支付宝", "2":"银行卡"}
                            ,formatter: Table.api.formatter.normal},
                        {field: 'mobile', title: __('User.mobile')},
                        {field: 'pay_account', title: __('Pay_account')},
                        {field: 'pay_name', title: __('Pay_name')},
                        // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},

                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});